package com.sanjiahantang.youjiaclient.module.match.models.impl;

import android.content.Context;
import android.util.Log;

import com.sanjiahantang.youjiaclient.base.CallBack;
import com.sanjiahantang.youjiaclient.config.ConfigValue;
import com.sanjiahantang.youjiaclient.http.BaseDelegate;
import com.sanjiahantang.youjiaclient.http.OkHttpClientManager;
import com.sanjiahantang.youjiaclient.module.match.beans.MatchBean;
import com.sanjiahantang.youjiaclient.module.match.beans.MatchListBean;
import com.sanjiahantang.youjiaclient.module.match.models.IMatchModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/16.
 */

public class MatchModel implements IMatchModel {
    @Override
    public void loadMatchList(final Context context, Map<String, Object> param, final CallBack<MatchListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/mall/together/phone/searchTogetherInfoForCustomer",param,new BaseDelegate.ResultCallback<MatchListBean>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(MatchListBean response, Object tag) {
                callBack.onSuccess(response,context, null);
            }
        });
    }

    @Override
    public void loadMatchDetail(final Context context, Map<String, String> param, final CallBack<MatchBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/mall/together/phone/findTogetherInfoForCustomer",param,new BaseDelegate.ResultCallback<MatchBean>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(MatchBean response, Object tag) {
                callBack.onSuccess(response,context, null);
            }
        });
    }
}
